package com.tbocek.android.ode.systems.loktavolterra;

import com.tbocek.android.ode.solver.ODESystem;
import com.tbocek.android.ode.solver.SystemState;

/**
 * A system of equations that implements a two-species Lokta-Volterra model.
 * @author Tim
 *
 */
public class LoktaVolterra extends ODESystem {
	
	private float mPreyGrowthRate;
	
	private float mPreyPredationCoefficient;
	
	private float mPredatorDeathRate;
	
	private float mPredatorPredationCoefficient;
	
	@Override
	public float[] computeDerivatives(SystemState state) {
		LoktaVolterraState s = (LoktaVolterraState)state;
		
		return LoktaVolterraState.createDerivativeArray(
				s.getPredatorCount() * -mPredatorDeathRate 
					+ mPredatorPredationCoefficient 
						* s.getPredatorCount() * s.getPreyCount(),
				s.getPreyCount() * mPreyGrowthRate 
					+ mPreyPredationCoefficient 
						* s.getPredatorCount() * s.getPreyCount());
	}

}
